package com.dreamcar.auction.entity;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * ComponentCarRelation entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "component_car_relation", catalog = "assignment")
public class ComponentCarRelation implements java.io.Serializable {

	// Fields

	private ComponentCarRelationId id;
	private Component component;
	private CarModel carModel;

	// Constructors

	/** default constructor */
	public ComponentCarRelation() {
	}

	/** full constructor */
	public ComponentCarRelation(ComponentCarRelationId id, Component component,
			CarModel carModel) {
		this.id = id;
		this.component = component;
		this.carModel = carModel;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides( {
			@AttributeOverride(name = "idComponent", column = @Column(name = "id_component", nullable = false)),
			@AttributeOverride(name = "idCarModel", column = @Column(name = "id_car_model", nullable = false)) })
	public ComponentCarRelationId getId() {
		return this.id;
	}

	public void setId(ComponentCarRelationId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_component", nullable = false, insertable = false, updatable = false)
	public Component getComponent() {
		return this.component;
	}

	public void setComponent(Component component) {
		this.component = component;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_car_model", nullable = false, insertable = false, updatable = false)
	public CarModel getCarModel() {
		return this.carModel;
	}

	public void setCarModel(CarModel carModel) {
		this.carModel = carModel;
	}

}